﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>jQuery不支持获取隐藏元素的偏移坐标</title>
    <style type="text/css">
        div
        {
            margin-left: 10px;
            color: #FF0000;
        }
    </style>
    <script src="../jquery-1.8.0.js" type="text/javascript"></script>
    <script type="text/javascript">
        window.onload = function () {
            $("p").click(function (e) {
                alert("Top :" + e.target.offsetTop + " Left:" + e.target.offsetLeft);
                var p = $("p:last");
                var offset = p.offset();     
                p.html("left: " + offset.left + ", top: " + offset.top);
            });

            $("p", document.body).each(function (key, value) {
                alert(key + " : " + $(this).html());
            });

            $("span", $("#div")).click(function () {
                alert($(this).html());
            });
        };
    </script>
</head>
<body>
    <div id="div">
        <div>
            Hello</div>
        <p>
            2nd Paragraph</p></br>
        <span>3nd span </span></br>
        <span>4nd span</span>
    </div>
</body>
</html>
